//
//  RealmData.swift
//  Example
//
//  Created by admin on 2020/9/1.
//  Copyright © 2020 admin. All rights reserved.
//

import Foundation
import RealmSwift

class UGRealmData: Object,Identifiable {
   
    @objc dynamic var id:String = UUID().uuidString //名字
    
    func ug_add()  {
        let realm = try! Realm()
        
        try! realm.write {
            realm.add(self)
            
        }
       print("添加成功")
    }
    class func ug_delete(id:String)  {
        let realm = try! Realm()
        let deletedata = realm.objects(self).filter("id=='\(id)'").first
        try! realm.write {
            realm.delete(deletedata!)
        }
        print("删除成功")
    }

}
